#ifndef _BUOLA_GL_CVERTEXARRAY_H_
#define _BUOLA_GL_CVERTEXARRAY_H_

#include <buola/gl.h>

namespace buola { namespace gl {

class CVertexArray
{
public:
    CVertexArray()
    {      
        glGenVertexArrays(1,&mID);
    }

    CVertexArray(const CVertexArray&)=delete;

    CVertexArray(CVertexArray &&pO)
        :   mID(pO.mID)
    {
        pO.mID=0;
    }
    
    ~CVertexArray()
    {
        if(mID) glDeleteVertexArrays(1,&mID);
    }

    CVertexArray &operator=(const CVertexArray&)=delete;

    CVertexArray &operator=(CVertexArray &&pO)
    {
        std::swap(mID,pO.mID);
        return *this;
    }

    void Bind()
    {
        glBindVertexArray(mID);
    }

    void Unbind()
    {
        glBindVertexArray(0);
    }

    GLuint ID() const       {   return mID;     }

private:
    GLuint mID;
};

/*namespace gl*/ } /*namespace buola*/ }

#endif
